<!-- 原材料 -->
<template>
  <div class="ctn-box ctn-box-2">
    <div class="ctn-box-title">
      <span>{{params?.monthParams}}月原材料支出</span>
      <div class="title-tab">
        <span :class="{'active': !tagActive}">月</span>
        <span :class="{'active': tagActive}">年</span>
      </div>
    </div>
    <div class="ctn-box-base">
      <!-- 排期铁用量 -->
      <div class="counts">
        <label>排期铁用量</label>
        <span v-for="t in total">{{t}}</span>
      </div>
      <!-- 其他参数 -->
      <div class="other-box">
        <div class="mark">铁线</div>
        <img src="@/assets/icons/material/icon1.png"/>
        <div class="other-box-details">
          <span>铁库存量</span>
          <label>10吨</label>
        </div>
      </div>
      <div class="other-box">
        <div class="mark">M09</div>
        <img src="@/assets/icons/material/icon2.png"/>
        <div class="other-box-details">
          <span>存量</span>
          <label>10吨</label>
        </div>
      </div>
      <div class="other-box">
        <div class="mark">ABS</div>
        <img src="@/assets/icons/material/icon3.png"/>
        <div class="other-box-details">
          <span>存量</span>
          <label>10吨</label>
        </div>
      </div>
      <div class="other-box">
        <div class="mark">HDPE</div>
        <img src="@/assets/icons/material/icon4.png"/>
        <div class="other-box-details">
          <span>存量</span>
          <label>10吨</label>
        </div>
      </div>
      <div class="other-box">
        <div class="mark">PP5090T</div>
        <img src="@/assets/icons/material/icon5.png"/>
        <div class="other-box-details">
          <span>存量</span>
          <label>10吨</label>
        </div>
      </div>
      <!-- 表格 -->
      <div class="ctn-box-2-table">
        <div class="tr table-head">
          <span class="ps1">购入日期</span>
          <span class="ps1">原材料名称</span>
          <span>购入金额</span>
          <span>购入数量</span>
        </div>
        <div class="table-body">
          <vue3-seamless-scroll
              ref="mtScroll"
              :list="expensesList"
              :limit-scroll-num="8"
              hover-stop="true"
          >
            <div class="tr" v-for="ml in materialList">
              <span class="ps1">2024.01.02</span>
              <span class="ps1">6.5原料线(迁安)</span>
              <span class="ps-y">30%</span>
              <span class="ps-y">30%</span>
            </div>
          </vue3-seamless-scroll>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import {computed, ref} from "vue";

defineOptions({
  name: 'materialView'
})

// 排铁用量
let counts = ref<number>(598)
// 排铁用量回显
const total = computed(()=>{
  if(counts.value > 0){
    const count = counts.value
    if (Number.isNaN(count)) return [0]
    return count.toString().split('')
  }
  return [0]
})
// 材料价格列表
let materialList = reactive([])
// false: 月；true： 年
const tagActive = ref<boolean>(false)
const params = defineProps({
  monthParams: {
    type: String,
    default: ''
  }
})
</script>

<style lang="scss" scoped>
.ctn-box-base{
  padding: 6px 8px;
  .counts{
    width: 100%;
    display: inline-flex;
    align-items: center;
    text-align: center;
    justify-content: center;
    label{
      margin-right: 27px;
    }
    span{
      display: inline-block;
      width: 30px;
      height: 40px;
      line-height: 60px;
      font-size: 30px;
      color: #FFFFFF;
      text-shadow: 0 3px 1px rgba(13,16,38,0.44);
      background: url("@/assets/icons/material/count-bg.png") center/100% 100% no-repeat;
      font-family: din-bold;
      margin: 0 3px;
    }
  }
  .other-box{
    display: flex;
    justify-content: space-between;
    width: 100%;
    height: 61px;
    background: url("@/assets/icons/material/material-other-box-bg.png") center/100% 100% no-repeat;
    position: relative;
    padding-left: 82px;
    padding-right: 10px;
    font-size: 14px;
    margin: 10px 0;
    &:last-child{
      margin-bottom: 25px;
    }
    img{
      position: absolute;
      top: 0;
      left: 0;
      width: 82px;
      height: 100%;
    }
    .mark{
      position: absolute;
      top: 0;
      right: 0;
      width: 59px;
      height: 17px;
      line-height: 17px;
      font-size: 12px;
      text-align: center;
      background: url("@/assets/icons/material/material-other-box-mark-bg.png") center/100% 100% no-repeat;
    }
    .other-box-details{
      display: inline-flex;
      align-items: center;
      span{
        width: 80px;
      }
      label{
        font-size: 18px;
        color: rgba(255, 185, 62, 1);
      }
    }
  }
  .ctn-box-2-table{
    height: calc(100% - 414px);
    .tr .ps1{
      width: 36%;
    }
    .table-body{
      width: 100%;
      height: calc(100% - 32px);
      overflow: auto;
      background: url("@/assets/icons/material/table-body-bg-2.png") center/100% 100% no-repeat;
      .tr{
        height: 53px;
        line-height: 53px;
        color: rgba(190, 212, 244, 1);
        border-bottom: 1px solid rgba(5, 38, 90, 1);
      }
    }
  }
}
</style>
